package post_to_in_pkg.node;

public class If_else_node extends Node{
	private OperandNode Condition;
	private Blocks If_stmts,Else_stmts;
	private boolean NOTIF_Flag=false;
	public If_else_node(OperandNode condition,Blocks block1,Blocks block2) {
		Condition=condition;
		If_stmts=block1;
		Else_stmts=block2;
	}
	
	public If_else_node(OperandNode condition,Blocks block1,Blocks block2, boolean flag){
		Condition=condition;
		If_stmts=block1;
		Else_stmts=block2;
		NOTIF_Flag=flag;
	}
	@Override
	public String toString() {
		// TODO Auto-generated method stub
		String s="";
		s="\nif("+Condition.toString()+") {\n"+If_stmts.toString()+"\n}\n";
		s=s+"else {\n"+Else_stmts.toString()+"\n}";
		return s;
	}

	@Override
	public boolean isReturnVoid() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean isTempNode() {
		// TODO Auto-generated method stub
		return false;
	}


	@Override
	public boolean hasChild() {
		// TODO Auto-generated method stub
		return If_stmts.hasChild()&&Else_stmts.hasChild();
	}


	@Override
	public void printChild(StringBuffer content) {
		// TODO Auto-generated method stub
		StringBuffer strbuf_if_stmt=new StringBuffer(),strbuf_else_stmt=new StringBuffer();
		if(Condition.hasChild())
			Condition.printChild(content);
		If_stmts.printChild(strbuf_if_stmt); Else_stmts.printChild(strbuf_else_stmt);
		String s="\nif("+Condition.getName()+"){\n"+
				strbuf_if_stmt.toString()+
				"\n}\n";
		if(Else_stmts.hasChild()) {
			s+="else{\n"+
					strbuf_else_stmt.toString()+
					"\n}\n";
		}
		content.append(s);
		
	}
	
}
